Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiP: galp5 build based on librem_11 (GOP based iGPU) #1774

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

tlaurion
Copy link
Collaborator

@tlaurion tlaurion commented Sep 3, 2024

@loftlifter31 this is my take helping you get the base to make this forward.

Superseeds #1766

@tlaurion tlaurion marked this pull request as draft September 3, 2024 14:49
@tlaurion
Copy link
Collaborator Author

tlaurion commented Sep 3, 2024

As per DCO CI warning https://github.com/linuxboot/heads/pull/1774/checks?check_run_id=29617868402, resigning all comits, making us co-authors.

Please sign commits form local git repo. Steal reuse my commit content and force push to your branch under #1766 (currently your master branch, otherwise ropen another PR, closing #1766 as per your choosing)

@tlaurion
Copy link
Collaborator Author

tlaurion commented Sep 3, 2024

Squashing all your commits to original work (no author etc)

@tlaurion
Copy link
Collaborator Author

tlaurion commented Sep 3, 2024

Rebase+squash+signoff detailed under 4418282 commit message

blobs/galp5/ifd.bin Outdated Show resolved Hide resolved
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this coming from @loftlifter31 ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally there is a script downloading me.rom from a specific commit, so that this repo doesn't grow with blobs, just like for other boards, see blobs scripts.

Alternatively, as other coreboot forks do, there is seperate blobs. Those might be under coreboot blobs already downloaded, I haven't verified either.

Tldr:we would merge a blog of 5mb in this tree that will change later.

See past blobs in their repo, changed 5+ times already https://github.com/system76/firmware-open/commits/master/models/galp5/me.rom

@@ -97,6 +97,13 @@ coreboot-dasharo_commit_hash := 3a9aa3a4692f3dd49732f5b4e3ec54be385f0969
coreboot-dasharo_patch_version := unreleased
$(eval $(call coreboot_module,dasharo,))

# System76 maintain their own fork
coreboot-system76_repo := https://github.com/system76/coreboot
coreboot-system76_commit_hash := 6da534f92044c684139675a599eef92d077b2b36
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tip of fork at time of writing system76/coreboot@6da534f

Copy link
Collaborator Author

@tlaurion tlaurion Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated using modules/coreboot Makefile helper. Feel free to finetune with:
docker run -e DISPLAY=$DISPLAY --network host --rm -ti -v $(pwd):$(pwd) -w $(pwd) tlaurion/heads-dev-env:latest -- make BOARD=galp5 coreboot.modify_and_save_oldconfig_in_place

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated using modules/linux Makefile helper. Feel free to finetune with:
docker run -e DISPLAY=$DISPLAY --network host --rm -ti -v $(pwd):$(pwd) -w $(pwd) tlaurion/heads-dev-env:latest -- make BOARD=galp5 linux.modify_and_save_oldconfig_in_place

# CONFIG_FB_IMSTT is not set
# CONFIG_FB_VGA16 is not set
# CONFIG_FB_VESA is not set
CONFIG_FB_EFI=y
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely needed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure what to put in this config file. The system76 build process doesn't use it since they use coreboot with an edk2 payload. I tried copying the config for the running kernel but that has a ton of multimedia drivers and created a monster sized kernel 80+ Mb. Too big for the rom. So in the end I just copied the linux config from another board. x230 I think since it uses close to the same kernel version 5.15 How will I know what FB to set here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure what to put in this config file. The system76 build process doesn't use it since they use coreboot with an edk2 payload. I tried copying the config for the running kernel but that has a ton of multimedia drivers and created a monster sized kernel 80+ Mb. Too big for the rom. So in the end I just copied the linux config from another board. x230 I think since it uses close to the same kernel version 5.15 How will I know what FB to set here?

Does it work?
It should be GOP (provided by fsp for iGPU to drive coreboot FB) and then efifb as said.

Only librem 11 is goon driven under heads today, everything else is libgfxinit driven under coreboot.

So if GOP initialize 2d FB enough so coreboot is happy with linear FB init, then efifb from kernel can reuse it, then you would be good to go on that level.

Test results?

Copy link
Collaborator Author

@tlaurion tlaurion Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this or is not based on x230 config anymore. Neither the same kernel ver, coreboot ver nor configs.

This is coreboot config derivate of librem 11, and coreboot fork using latest commit from their coreboot fork.

Have you reviewed all the changes? See individual commit logs and file changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loftlifter31 system76 coreboot fork seems to be missing some patches from upstream. See patches/coreboot-24.02.01 for reference, added HEAP_SIZE patch needed for bootsplash to work, others might be missing

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFIG_FB_EFI=y works ok in the linux.config file. If additional info is needed on this, I can post the relevant lines from the compile config file used to build the kernel that shipped with the laptop.

Comment on lines +549 to +554
CONFIG_HAVE_LINEAR_FRAMEBUFFER=y
CONFIG_HAVE_FSP_GOP=y
# CONFIG_VGA_ROM_RUN is not set
CONFIG_RUN_FSP_GOP=y
# CONFIG_NO_GFX_INIT is not set
CONFIG_NO_EARLY_GFX_INIT=y
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should work, as for librem_11

Copy link
Collaborator Author

@tlaurion tlaurion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you go, commented in code @loftlifter31. CircleCI will produce ROM to be tested, as per https://osresearch.net/Downloading#downloading-heads-from-circleci but from this PR built artifacts.

WARNING: this is just first iteration, I do not own the hardware and cannot test. This is first iteration, where GOP/vbt/EFIFB will most probably need some additional work. If this doesn't boot, we can activate debbuging traces to be saved in SPI, and taking a backup there, increasing debug levels and extracting coreboot logs will push this forward.

CONFIG_MOBILE_TETHERING=y

export CONFIG_TPM=y
export CONFIG_SUPPORT_USB_KEYBOARD=y
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how the keyboard is connected. If PS2, remove.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a laptop so the keyboard is built in.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a laptop so the keyboard is built in.

Doesn't mean much unfortunately without having laptop in hands. It either needs to be ps2/usb and if usb, drivers needs to loaded early under Heads.

Hence why I raise your attention there.
Its cheaper for manufacturers nowaday to do usb, many do that. I dunno their implementation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tlaurion CONFIG_SUPPORT_USB_KEYBOARD=y allows the user to enable USB keyboard support in config. It's off by default. I provide this for Librems due to popular demand.

You're thinking of CONFIG_USB_KEYBOARD_REQUIRED=y which means the device only has USB keyboards.

I'm not familiar with this hardware, but typically the internal keyboard is a PS/2 keyboard (well, really provided by the EC as an 8042 interface, no actual PS/2 port or signaling, but I digress). So I think you have this right @loftlifter31

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loftlifter31 optional, runtime configurable option under 76d2dc8

Comment on lines +153 to +154
CONFIG_IFD_BIN_PATH="@BLOB_DIR@/galp5/ifd.bin"
CONFIG_ME_BIN_PATH="@BLOB_DIR@/galp5/me.bin"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Points to your blobs. Not checked validity

CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y
CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y
CONFIG_RTC=y
CONFIG_HEAP_SIZE=0x100000
Copy link
Collaborator Author

@tlaurion tlaurion Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to be bumped to 0x400000 otherwise no bootsplash. Patch under purism fork and 24.02.01 patches/dir

This comment was marked as outdated.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. There is no bootplash at this setting, but that is not a problem for me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we trying to get galp5 for your sole usage or for everybody else? That will change my involvement in this effort.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My primary concern at this point is to get it working for myself according to my needs. However, I don't see any problem with testing alternate configurations which may benefit others, such as increasing the heap size.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, nope. Sorry, coreboot forks have their own logic, and doing real.clean* doesn't remove the .patched flag.
Working on a fix and pushing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha. Realized the two patches were abandoned and https://review.coreboot.org/c/coreboot/+/83895 was merged instead.... @JonathonHall-Purism

Copy link
Collaborator Author

@tlaurion tlaurion Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wait and see if 127e5df and #1795 builds from CI.

If not, https://review.coreboot.org/c/coreboot/+/83894/2 might as well be needed.

Copy link
Collaborator Author

@tlaurion tlaurion Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neglect #1774 (comment) referred patches, deleted in latest commit here and under #1795

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still no bootsplash with heap set to 0x400000

Copy link
Collaborator Author

@tlaurion tlaurion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments

@tlaurion
Copy link
Collaborator Author

tlaurion commented Sep 4, 2024

Here you go, commented in code @loftlifter31. CircleCI will produce ROM to be tested, as per https://osresearch.net/Downloading#downloading-heads-from-circleci but from this PR built artifacts.

WARNING: this is just first iteration, I do not own the hardware and cannot test. This is first iteration, where GOP/vbt/EFIFB will most probably need some additional work. If this doesn't boot, we can activate debbuging traces to be saved in SPI, and taking a backup there, increasing debug levels and extracting coreboot logs will push this forward.

@loftlifter31 did you test galp5 built rom artifact from this PR?

@tlaurion
Copy link
Collaborator Author

tlaurion commented Sep 5, 2024

Here you go, commented in code @loftlifter31. CircleCI will produce ROM to be tested, as per https://osresearch.net/Downloading#downloading-heads-from-circleci but from this PR built artifacts.

WARNING: this is just first iteration, I do not own the hardware and cannot test. This is first iteration, where GOP/vbt/EFIFB will most probably need some additional work. If this doesn't boot, we can activate debbuging traces to be saved in SPI, and taking a backup there, increasing debug levels and extracting coreboot logs will push this forward.

@loftlifter31 did you test galp5 built rom artifact from this PR?

@loftlifter31 after following referred downloading doc page, you should have landed to https://output.circle-artifacts.com/output/job/5c445ab2-7bfa-4ed5-8b35-1e3993322e0f/artifacts/0/build/x86/galp5/heads-galp5-v0.2.0-2303-g9638cdb.zip

@tlaurion
Copy link
Collaborator Author

tlaurion commented Sep 5, 2024

Oh. Librem 11 is not a board config with tpm2 dependencies. So above rom might boot with FB and console output or not, but t+heads rom toolstack won't work. Board config needs to be adapted from another board that is tpm2, ie nv41.

@tlaurion
Copy link
Collaborator Author

tlaurion commented Sep 5, 2024

Oh. Librem 11 is not a board config with tpm2 dependencies. So above rom might boot with FB and console output or not, but t+heads rom toolstack won't work. Board config needs to be adapted from another board that is tpm2, ie nv41.

fixed under 2db9de9


#On-demand hardware support (modules.cpio)
CONFIG_LINUX_USB=y
CONFIG_LINUX_E1000=y
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loftlifter31 unclear what ethernet controller is present under HCL https://tech-docs.system76.com/models/galp5/README.html you might need to adapt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why I would need ethernet during boot up. Once control is passed to full linux kernel that will take care of loading correct drivers, yes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why I would need ethernet during boot up. Once control is passed to full linux kernel that will take care of loading correct drivers, yes?

This driver needs to be right (e1000e, igb whatnot) to be able to use network-init-recovery script (which syncs time through ntp and get an address from dhcp prior) from recovery shell today. It's completely on demand and nothing today does the loading of the driver automatically outside of this codepath.

Heads hopefully will evolve into squashfs+overlayfs overlays so that things can be pulled from the network (wyng, docker whatever) depending of the use case pushed by the oem down to its users (dasharo DTS being one desired case, to bypass need of ipxe: we could wget kernel +initrd and kexec into it), another one being python3 overlayfs to jump into getting system state restoration as a service.

Note that the board config as it is already included android network tethering drivers also prompting the user to be used transparently through network-init-recovery today.

Tldr: on demand network access, loading drivers not on standard boot path, measures then load additional drivers, changing PCR content and preventing heads to release secrets that were sealed to unseal only on default boot path. So loading any on-demand driver will prevent efficiently any secret to be unsealed. Same applies to recovery shell access: doing on demand operations extend PCR banks which invalidates measurements .

Todo: Getting the right Ethernet driver there is needed for on-demand networking. Gotta figure out if it's igb e1000 or e1000e

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs say it should come with Intel NIC however mine seems to come with Realtek 8111 chipset.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs say it should come with Intel NIC however mine seems to come with Realtek 8111 chipset.

need actual loaded driver and dependencies from booted linux os lsmod

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

driver is r8169. No listed dependencies.

Copy link
Collaborator Author

@tlaurion tlaurion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more changes following previous comments

Comment on lines +760 to +761
CONFIG_CONSOLE_SPI_FLASH=y
CONFIG_CONSOLE_SPI_FLASH_BUFFER_SIZE=0x20000
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loftlifter31 this is console output (equivalent of cbmem console output) saved in SPI.
0x20000 might not be enough, and more debugging activation might be needed.

But this will permit to take a falshrom/flashprog backup externally and investigate the content in case of a bricked system and post those logs to make this go faster in case EFIFB/libgfxinit/GOP not working as expected.

Copy link
Collaborator Author

@tlaurion tlaurion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loftlifter31 logs/trace of current PR status expected to move things formward. I think this is now a good starting base to iterate upon, unless system76 coreboot fork's latest commit (unmoving for months, not sure of their base (24.02.01? didn't check) is wrong for non UEFI setups. Then if that is the case, more work will need to be done in collaboration of system76.

Artifacts of last commit will be available under https://app.circleci.com/pipelines/github/tlaurion/heads/2817/workflows/492b18c9-7b8d-4600-b027-188e8d1b3658 select galp5, artifacts, and zip file. Decompress, sha256sum -c checksum_file_from_zip, flash, test, backup rom, and share here as tgz.

@tlaurion
Copy link
Collaborator Author

tlaurion commented Sep 9, 2024

From #1765 (comment)

I got it working. Just needed to update vbt.

That was relevant to system76/firmware-open#575 (comment), not Heads issue.

Can you create a branch with everything tested working on your side? Like I said, HEAP size bumped to 40000 should work even with bootsplash if GOP + vbt+ efifb works. Some output would be great. Will rebase this branch on master and force push.

After that, I will let this PR bitrot until picked up to be upstreamed.

loftlifter31 and others added 15 commits September 9, 2024 13:48
squashed and signed off doing
- git log
 - copy commit ID from where to squash and sign (xxxx)
- git rebase --signoff -i xxxx^
 - follow GUI, here 'e' to edit oldest commit log message, all others to be squashed were tagged 's' for squash
   - edited commit message by git commit --signoff --amend
   - continued rebase by doing git rebase --continue
   - after rebase, all commits to be squashed commit messages on screen, delete all irrelevant.

Signed-off-by: Thierry Laurion <[email protected]>
… librem_11 GOP based changes

Signed-off-by: Thierry Laurion <[email protected]>
…y config as comments based on qemu-coreboot-fbwhiptail-tpm2-hotp

Signed-off-by: Thierry Laurion <[email protected]>
…oreboot-24.02.01/0002-increase_heap_from1mb_to4mb_when_bootpslash_enabled.patch to patches/coreboot-system76-unrelease. Others might be needed, see patches/coreboot-24.02.01/*

Signed-off-by: Thierry Laurion <[email protected]>
… have flash externally backup and inspected

TODO: turn on additional debugging in case more is needed with
docker run -e DISPLAY=$DISPLAY --network host --rm -ti -v $(pwd):$(pwd) -w $(pwd) tlaurion/heads-dev-env:latest -- make BOARD=galp5 coreboot.modify_and_save_oldconfig_in_place

in DEBUGGING settings of coreboot menuconfig menu.

Signed-off-by: Thierry Laurion <[email protected]>
…patch_rebuild_what_changed helper deletes coreboot .patched files so that a rebuild will patch coreboot if needed

Signed-off-by: Thierry Laurion <[email protected]>
… failure. Add https://review.coreboot.org/c/coreboot/+/83895

Repro:
rm patches/coreboot-24.02.01/0001* patches/coreboot-24.02.01/0002*
git fetch https://review.coreboot.org/coreboot refs/changes/94/83894/2 && git format-patch -1 --stdout FETCH_HEAD > patches/coreboot-24.02.01/0001-vc_wuffs-upgrade-to-Wuffs_0.4.0-alpha.8.patch
git fetch https://review.coreboot.org/coreboot refs/changes/95/83895/3 && git format-patch -1 --stdout FETCH_HEAD > patches/coreboot-24.02.01/0002-lib_jpeg-avoidcalling-malloc-and-free.patch
cp patches/coreboot-24.02.01/0001* patches/coreboot-system76-unreleased/
cp patches/coreboot-24.02.01/0002* patches/coreboot-system76-unreleased/
sed -i 's/CONFIG_HEAP_SIZE=0x400000/CONFIG_HEAP_SIZE=0x100000/g' config/coreboot-*

Signed-off-by: Thierry Laurion <[email protected]>
@tlaurion
Copy link
Collaborator Author

tlaurion commented Sep 11, 2024

37f809e

Tested equivalent under #1795 under qemu: works without needing to change HEAP_SIZE. See commit details.

Tested local build: patches applies.

artifacts for 37f809e galp board should drive FB and be working, outside of on-demand ethernet enabling as previously discussed.

@loftlifter31 you should get bootsplash from this PR artifacts since you said only bootsplash was missing. So EFIFB drives FB. Missing etherent needed realtek drivers which might already be under modules/linux. If so, change board config for config name, make sure galp5 linux config compiles those modules as kernel and deactivate e1000e, unneeded (?)

Confused on your last statement saying its supposed to come with some ethernet but came with realtek. Makes me question their HCL (and changes of internal hardware at will: confusing).

I won't be able to do much more on this before october. Keep me posted.

@loftlifter31
Copy link

Can you create a branch with everything tested working on your side? Like I said, HEAP size bumped to 40000 should work even with bootsplash if GOP + vbt+ efifb works. Some output would be great. Will rebase this branch on master and force push.

Create a branch? Where? On my local fork? At this point everything on my fork is tested, though bootsplash and NIC are not working.

@tlaurion
Copy link
Collaborator Author

tlaurion commented Oct 2, 2024

Can you create a branch with everything tested working on your side? Like I said, HEAP size bumped to 40000 should work even with bootsplash if GOP + vbt+ efifb works. Some output would be great. Will rebase this branch on master and force push.

Create a branch? Where? On my local fork? At this point everything on my fork is tested, though bootsplash and NIC are not working.

37f809e is supposed to fix bootsplash. This PR includes fixes for your reported issues, leaving ethernet support to be figured out (you said card present is not as from upstream HCL, so didn't fixed this here, but showed ropes on how to do this (add drivers under modules/linux, add those compiled as modules, review modules loading scripts etc: all can be done later, this PR if made to work with blobs injected in would be useable by other galp5 owners desiring Heads. But work needs to be done to arrive there.

@loftlifter31 Putting this as draft, seems we are not aligned to make this first candidate and make this work for others as all other boards. When you are ready, let me know. Letting this bitrot as draft.

@tlaurion tlaurion marked this pull request as draft October 2, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants